package ch3stacks;

class ArrayStack {
	int stackSize = 300;
	int[] buffer = new int[stackSize * 3];
	int[] stackPointer = { 0, 0, 0 }; // stack pointers to track top elem

	void push(int stackNum, int value) {
		int index = stackNum*stackSize + stackPointer[stackNum];
		buffer[index] = value;
		stackPointer[stackNum]++;
	}

	int pop(int stackNum) {
		int index = stackNum*stackSize + stackPointer[stackNum] - 1;
		stackPointer[stackNum]--;
		int value = buffer[index];
		buffer[index] = 0;
		return value;
	}

	int peek(int stackNum) {
		int index = stackNum*stackSize + stackPointer[stackNum] - 1;
		return buffer[index];
	}

	boolean isEmpty(int stackNum) {
		return stackPointer[stackNum] == 0;
	}
}

public class Ex1 {

}
